package com.codingxyz.simple.volatiles;


import java.util.concurrent.TimeUnit;

public class VolatileDemo {

    public static void main(String[] args) {

        MyData data = new MyData();

        new Thread(()->{
            System.out.println(Thread.currentThread().getName()+" \t come in ");
            try {
                TimeUnit.SECONDS.sleep(3);
                data.addT060();
                System.out.println(Thread.currentThread().getName() + "\t update number value : "+data.number);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        },"AAA").start();



        while (data.number==0){
        }

        System.out.println(Thread.currentThread().getName() + "\t number "+data.number);
    }




}
